#include <cgicc/Cgicc.h>
#include "../ConnectMsg.h"
#include "CgiWrapper.h"

using namespace cgicc;

int main()
{
    try
    {
	Cgicc formData;

	form_iterator errCode = formData.getElement("errCode");
	form_iterator submitType = formData.getElement("submitType");

	CGIWrapper cgi;
	cgi.HTMLHeader();
	cgi.BeginHtml();
	cgi.BeginHead("Error");
	cgi.EndHead();
	cgi.BeginBody();
	
	cgi.H1("Error page");
	switch ((QueryResult)atoi((**errCode).c_str()))
	{
	case USERNAME_EMPTY:
	    cgi.HtmlText("Username empty!");
	    break;
	case PASSWORD_EMPTY:
	    cgi.HtmlText("Password empty!");
	    break;
	case USERNAME_EXIST:
	    cgi.HtmlText("Username exist!");
	    break;
	case USERNAME_NOT_EXIST:
	    cgi.HtmlText("Username not exist!");
	    break;
	case PASSWORD_ERROR:
	    cgi.HtmlText("Password error!");
	default:
	    cgi.HtmlText("Error Code:");
	    cgi.HtmlText(**errCode);    
	}
	cgi.EndBody();
	cgi.EndHtml();
    }
    catch(...)
    {

    }
}
